home *** CD-ROM | disk | FTP | other *** search
/ Aminet 16 / Aminet 16 (1996)(GTI - Schatztruhe)[!][Dec 1996].iso / Aminet / dev / src / wangisrc.lha / wangi / z / wpad_library / WP_OpenPad.c < prev    next >
C/C++ Source or Header  |  1995-08-27  |  5KB  |  145 lines

  1. /***************************************************************************
  2.  * WP_OpenPad.c
  3.  *
  4.  * wpad.library, Copyright ©1995 Lee Kindness.
  5.  *
  6.  * WP_OpenPad()
  7.  */
  8.  
  9. #include "wpad_global.h"
  10.     
  11. /****** wpad.library/WP_OpenPadA ******************************************
  12. *
  13. *   NAME 
  14. *       WP_OpenPadA - Allocate and open a pad.
  15. *
  16. *   SYNOPSIS
  17. *       pad = WP_OpenPadA ( tags );
  18. *       d0                  a0
  19. *
  20. *       struct Pad *WP_OpenPadA ( struct TagItem * );
  21. *
  22. *       pad = WP_OpenPad ( Tag tag1, ... );
  23. *       d0                 a0
  24. *
  25. *       struct Pad *WP_OpenPad( tag1, ... )
  26. *
  27. *   FUNCTION
  28. *
  29. *   INPUTS
  30. *       tags - 
  31. *
  32. *   RESULT
  33. *
  34. *   EXAMPLE
  35. *
  36. *   NOTES
  37. *
  38. *   BUGS
  39. *
  40. *   SEE ALSO
  41. *       dos.library/CreateNewProc(), intuition.library/OpenWindowTagList(),
  42. *       gadtools.library/CreateGadgetA()
  43. *
  44. *****************************************************************************
  45. *
  46. */
  47.  
  48. struct Pad LIBENT *WP_OpenPadA( REG(a0) struct TagItem *tags )
  49. {
  50.     struct Pad *res;
  51.     BOOL success;
  52.     //struct EasyStruct ez = {
  53.     //    sizeof(struct EasyStruct),
  54.     //    0,
  55.     //    "wpad.library",
  56.     //    "0x%06lx = OpenPad( 0x%06lx )",
  57.     //    "Ok"
  58.     //};
  59.     
  60.     res = NULL;
  61.     success = FALSE;
  62.     
  63.     /* Check tags and Allocate a pad */
  64.     if( (FindTagItem(WPOP_Items, tags)) &&
  65.         (FindTagItem(WPOP_Font, tags)) &&
  66.         (res = AllocVec(sizeof(struct Pad), MEMF_CLEAR)) )
  67.     {
  68.         struct TagItem *tag;
  69.         
  70.         /* Search and parse process tags */
  71.         
  72.         GETTAG(WPOP_Items, res->pad_Items, NULL, (struct List *), tags, tag);
  73.         
  74.         if( tag = FindTagItem(WPOP_Font, tags) )
  75.         {
  76.             res->pad_TAFont = (struct TextAttr *)tag->ti_Data;
  77.             res->pad_TFont = OpenDiskFont(res->pad_TAFont);
  78.         }
  79.         
  80.         /* We must have the above tags... */
  81.         if( res->pad_Items &&
  82.             res->pad_TAFont &&
  83.             res->pad_TFont )
  84.         {
  85.             LONG WPOP_StackSize_D, WPOP_Priority_D;
  86.             STRPTR WPOP_ProcName_D;
  87.             BPTR WPOP_CurrentDir_D;
  88.             struct TagItem *WPOP_CNPTags_D;
  89.             
  90.             GETTAG(WPOP_ProcName, WPOP_ProcName_D, DEF_WPOP_ProcName, (STRPTR), tags, tag);
  91.             GETTAG(WPOP_StackSize, WPOP_StackSize_D, DEF_WPOP_StackSize, (LONG), tags, tag);
  92.             GETTAG(WPOP_Priority, WPOP_Priority_D, DEF_WPOP_Priority, (LONG), tags, tag);
  93.             GETTAG(WPOP_CurrentDir, WPOP_CurrentDir_D, DEF_WPOP_CurrentDir, (BPTR), tags, tag);
  94.             GETTAG(WPOP_LeftEdge, res->pad_OrgLeft, DEF_WPOP_LeftEdge, (LONG), tags, tag);
  95.             GETTAG(WPOP_TopEdge, res->pad_OrgTop, DEF_WPOP_TopEdge, (LONG), tags, tag);
  96.             GETTAG(WPOP_Width, res->pad_OrgWidth, DEF_WPOP_Width, (LONG), tags, tag);
  97.             GETTAG(WPOP_Height, res->pad_OrgHeight, DEF_WPOP_Height, (LONG), tags, tag);
  98.             GETTAG(WPOP_Hook, res->pad_Hook, DEF_WPOP_Hook, (struct Hook *), tags, tag);
  99.             GETTAG(WPOP_Menu, res->pad_Menu, DEF_WPOP_Menu, (struct Menu *), tags, tag);
  100.             GETTAG(WPOP_PubScreenName, res->pad_PSName, DEF_WPOP_PubScreenName, (STRPTR), tags, tag);
  101.             GETTAG(WPOP_ScrollerWidth, res->pad_ScrollW, DEF_WPOP_ScrollerWidth, (LONG), tags, tag);
  102.             GETTAG(WPOP_Flags, res->pad_Flags, DEF_WPOP_Flags, (ULONG), tags, tag);
  103.             GETTAG(WPOP_Title, res->pad_Title, DEF_WPOP_Title, (STRPTR), tags, tag);
  104.             GETTAG(WPOP_ScreenTitle, res->pad_ScrTitle, DEF_WPOP_ScreenTitle, (STRPTR), tags, tag);
  105.             GETTAG(WPOP_Iconify, res->pad_Iconify, DEF_WPOP_Iconify, (LONG), tags, tag);
  106.             GETTAG(WPOP_Broker, res->pad_Broker, DEF_WPOP_Broker, (CxObj *), tags, tag);
  107.             GETTAG(WPOP_HotKey, res->pad_HotKey, DEF_WPOP_HotKey, (STRPTR), tags, tag);
  108.             GETTAG(WPOP_IconifyIcon, res->pad_IconName, DEF_WPOP_IconifyIcon, (STRPTR), tags, tag);
  109.             GETTAG(WPOP_State, res->pad_State, DEF_WPOP_State, (LONG), tags, tag);
  110.             GETTAG(WPOP_CNPTags, WPOP_CNPTags_D, DEF_WPOP_CNPTags, (struct TagItem *), tags, tag);
  111.             GETTAG(WPOP_OWTTags, res->pad_OWTTags, DEF_WPOP_OWTTags, (struct TagItem *), tags, tag);
  112.             GETTAG(WPOP_CGTags, res->pad_CGTags, DEF_WPOP_CGTags, (struct TagItem *), tags, tag);
  113.             GETTAG(WPOP_LMTags, res->pad_LMTags, DEF_WPOP_LMTags, (struct TagItem *), tags, tag);
  114.         
  115.             //GETTAG(WPOP_, res->pad_, DEF_WPOP_, (), tags, tag);
  116.             
  117.             /* Create the pad process/thread */
  118.             if( res->pad_Process = CreateNewProcTags(
  119.                  NP_Entry, WPP_Entry,
  120.                  NP_StackSize, WPOP_StackSize_D,
  121.                  NP_Name, WPOP_ProcName_D,
  122.                  NP_Priority, WPOP_Priority_D,
  123.                  NP_Output, Open("CON:557/11/100/250/wpad Output/AUTO/WAIT", MODE_READWRITE),
  124.                  NP_ExitData, res, /* Hide the pad structure :) */
  125.                  WPOP_CNPTags ? TAG_MORE : TAG_END, WPOP_CNPTags_D) )
  126.             {
  127.                 success = TRUE;
  128.             }
  129.         }
  130.     }
  131.     
  132.     if( !success )
  133.     {
  134.         if( res )
  135.         {
  136.             FreeVec(res);
  137.             res = NULL;
  138.         }
  139.     }
  140.     
  141.     //EasyRequest(NULL, &ez, NULL, res, tags);
  142.  
  143.     return( res );
  144. }
  145.